#ifndef VCDPING_H
#define VCDPING_H

#include <glib.h>

// eg:  delay:162,pkt_loss_rate:25
//      delay:162 ms,pkt_loss_rate:25%
typedef struct st_vcd_ping{
    // millisecond
    // the delay to server
    float delay;

    // packet loss rate
    int pkt_loss_rate;

    // set by vcd_ping_start
    // maybe is null
    gpointer priv;
}StVcdPingVar;

typedef void (*VCD_PING_CALLBACK)(StVcdPingVar* ctx);

struct StVcdPingCtx{
    gboolean (*start)(VCD_PING_CALLBACK callback, gpointer priv);
    void     (*stop)();
};


gboolean vcd_ping_start(VCD_PING_CALLBACK callback, gpointer priv);
void     vcd_ping_stop();

gboolean vcd_ping_is_port_open(const char* host,guint port);

#endif // VCDPING_H
